#include "camerainfo.h"

CameraInfo::CameraInfo() {}

bool CameraInfo::WriteXML(QXmlStreamWriter &writer){
    // 写入当前操作的信息
    writer.writeStartElement("CameraInfo");
    writer.writeAttribute("IP",m_strIPAddress);
    writer.writeAttribute("MAC",m_strMACAddress);
    writer.writeAttribute("name",m_strName);
    writer.writeAttribute("numbers",m_strCameraIdentifiers);
    writer.writeEndElement();
    return true;
}

void CameraInfo::SetIPAddress(QString value){
    m_strIPAddress = value;
}

void CameraInfo::SetMACAddress(QString value){
    m_strMACAddress = value;
}

void CameraInfo::SetName(QString value){
    m_strName = value;
}

void CameraInfo::SetCameraIdentifiers(QString value){
    m_strCameraIdentifiers = value;
}

QString CameraInfo::GetName(){
    return m_strName;
}

QString CameraInfo::GetIPAddress(){
    return m_strIPAddress;
}

QString CameraInfo::GetMACAddress(){
    return m_strMACAddress;
}

QString CameraInfo::GetCameraIdentifiers(){
    return m_strCameraIdentifiers;
}

bool CameraInfo::ReadXML(QXmlStreamReader &reader){
    QXmlStreamAttributes attributes = reader.attributes();
    if(attributes.hasAttribute("IP")) {
        m_strIPAddress = attributes.value("IP").toString();
    }
    if(attributes.hasAttribute("MAC")) {
        m_strMACAddress = attributes.value("MAC").toString();
    }
    if(attributes.hasAttribute("name")) {
        m_strName = attributes.value("name").toString();
    }
    if(attributes.hasAttribute("numbers")) {
        m_strCameraIdentifiers = attributes.value("numbers").toString();
    }

    QXmlStreamReader::TokenType token = reader.readNext();
    return true;
}

